﻿@using PNProject
@model IEnumerable<PNProject.EF.Product>
@{
    ViewBag.Title = "Products";
    Layout = "~/Views/Shared/_Layout1.cshtml";
    string caname = ViewData["caname"].ToString();
    int caid = (int)ViewData["caid"];
}
<input id="caname" value="@caname" type="hidden" />
<input id="caid" value="@caid.ToString()" type="hidden" />
<div class="boxproducts">
    @foreach (var item in @Model)
    {
        var defaultImage = item.Avatar;
        <div class="boxpro">
        <div class="picpro-1">
            <table cellspacing="0" cellpadding="0" width="100%">
                <tbody>
                    <tr>
                        <td class="pic_1">
                            <a href="@Url.Action("Index","ProductDetails",new {CatelogId = @item.CategoryID,id = @item.ProductID})">
                                <img src="@defaultImage" alt=""/>
                            </a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <a href="@Url.Action("Index","ProductDetails",new {CatelogId = @item.CategoryID,id = @item.ProductID})">@item.Name</a>
    </div>
    }

</div>
<script type="text/javascript">
    $(document).ready(function () {
        $(".titlesub p").empty();
        var lang = document.URL.indexOf("en-US") < 0 ? true : false;
        var langtext = "";
        if (lang) {
            $(".titlesub p").append("Sản phẩm - Dịch vụ");
            $("#ulink_home a").append("Trang chủ");
            $("#ulink_child a").append("Sản phẩm & Dịch vụ");
            $("#ulink_child a").attr("href", "/products");
        }
        else {
            $(".titlesub p").append("Products & Services");
            $("#ulink_home a").append("Home");
            $("#ulink_home a").attr("href", "/en-US/home");
            $("#ulink_child a").append("Products & Services");
            $("#ulink_child a").attr("href", "/en-US/products");
            langtext = "/en-US";
        }

        var caname = $("#caname").val();
        var caid = $("#caid").val();
        if (caname != "") {
            $(".titlesub p").empty();
            $(".titlesub p").append(caname);
            var url = langtext + "/products/index/" + caid;
            $(".ulink ul").append("<li><p>&raquo;</p></li>");
            $(".ulink ul").append("<li><a href=" + url + ">" + caname + "</a></li>");
        }
    });
</script>